<cfsetting enablecfoutputonly="Yes">

<!--- 
  /**
   * This file should generate a script that looks something like this:
   *
   * function check_empty( form2check )
   * {
   *   if( 
   *       Validation.isBlankField( form2check.fuseaction, "" ) ||
   *       Validation.isBlankField( form2check.USERNAME, "" ) ||
   *       Validation.isBlankField( form2check.PASSWORD, "" ) ||
   *     )
   *     return false;
   *   else
   *     return true;
   * }
   * 
   * set the onsubmit of your form to 'return check_empty( this );'
   * for the script to work properly (and use a submit button instead of a
   * button with an onclick)
   * 
   * PS: it would be nice if we had a try/catch statement near the evaluate
   * inside the cfscript. If we transfer to MX we could implement that.
   *
   * @author  auke@vanleeuwen.net
   * @version 1.0 - 2003.11.12
   */
--->

<cfsavecontent variable="sHeaderText">

<cfscript>
  if( not isDefined( "attributes.sScriptName" ))       { attributes.sScriptName       = "checkEmpty"; }
  if( not isDefined( "attributes.lFieldsBlank" ))      { attributes.lFieldsBlank      = ""; }
  if( not isDefined( "attributes.lFieldsValidEmail" )) { attributes.lFieldsValidEmail = ""; }
  if( not isDefined( "attributes.sBlankAlertPrefix" )) { attributes.sBlankAlertPrefix = "The following field is required: "; }
  if( not isDefined( "attributes.sEmailAlertPrefix" )) { attributes.sEmailAlertPrefix = "Please enter a valid email: "; }
  if( not isDefined( "attributes.sScriptRoot" ))       
  { 
    if( isDefined( "request.skcm.scriptroot" ))
      attributes.sScriptRoot = request.skcm.scriptroot;
    else /* [avl] try scripts.e-linewebsolutions.nl */
      attributes.sScriptRoot = "http://scripts.e-linewebsolutions.nl";
  }
 
  /* set some variables */
  bFirstOne = true;
    
  /* check for an site-wide end-of-line character, if it's not defined, define it as a 'windows'-eoln */
  if( not isDefined( "attributes.sEol" )) 
    if( isDefined( "request.sEol" )) 
      sEol = request.sEol;
    else
      sEol = chr( 13 ) & chr( 10 );
  else
    sEol = attributes.sEol;
  
  /* include the javascript that has the validation object */
  writeOutput( '<scr' & 'ipt language="JavaScript" type="text/javascript" src="#attributes.sScriptRoot#/scr_validate.js"></sc' & 'ript>' & sEol );
 
  /* start the javascript with the actual 'check-function' */
  writeOutput( '<scr' & 'ipt language="Javascript" type="text/javascript">' & sEol );
  writeOutput( '<!--' & sEol );
  writeOutput( '  function #attributes.sScriptName#( form2check )' & sEol );
  writeOutput( '  {' & sEol );
  writeOutput( '    if( ' & sEol);
 
  /*******************************************************/
  /* start out with the regular 'check for blank' fields */
  /*******************************************************/
  for( x = 1; x lte listLen( attributes.lFieldsBlank, "|" ); x = x + 1 )
  {
    /* attributes.lFieldsBlank is a list like this: <formname>,<alert>|<formname2><alert2>| ... */
    sItem  = listGetAt( attributes.lFieldsBlank, x, "|" );
    sField = listGetAt( sItem, 1 ); 
    sAlert = listGetAT( sItem, 2 ); 
    if( not bFirstOne ) writeOutput( ' || ' & sEol );
    writeOutput( '      Validation.isBlankField( form2check.#sField#, "' );
    writeOutput( '#JSStringFormat( attributes.sBlankAlertPrefix & sAlert )#" )' ); /* evaluate */
      
    bFirstOne = false; /* we allready had one if we came here */
  }
 
  /*******************************************************/
  /*       check for any email validation fields         */
  /*******************************************************/
  for( x = 1; x lte listLen( attributes.lFieldsValidEmail, "|" ); x = x + 1 )
  {
    /* attributes.lFieldsValidEmail is a list like this: <formname>,<alert>|<formname2><alert2>| ... */
    sItem  = listGetAt( attributes.lFieldsValidEmail, x, "|" );
    sField = listGetAt( sItem, 1 ); 
    sAlert = listGetAT( sItem, 2 ); 
    if( not bFirstOne ) writeOutput( ' || ' & sEol );
    writeOutput( '      !Validation.isValidEmail( form2check.#sField#.value, "' );
    writeOutput( '#JSStringFormat( attributes.sEmailAlertPrefix & sAlert )#" )' ); /* evaluate */
      
    bFirstOne = false; /* we allready had one if we came here */
  }
  
  writeOutput( sEol & '      )' & sEol );
  writeOutput( '      return false;' & sEol );
  writeOutput( '    else' & sEol );
  writeOutput( '      return true;' & sEol );
  writeOutput( '  }' & sEol );
  writeOutput( '//-->' & sEol );
  writeOutput( '</scr' & 'ipt>' & sEol );
</cfscript>
 
</cfsavecontent>
 
<!--- [avl] voor de puriteinen onder ons --->
<cfif isDefined( "attributes.sSpacing" ) and not len( trim( attributes.sSpacing ))>
  <cfhtmlhead text="#replaceNoCase( sHeaderText, request.s_EOL, request.s_EOL & attributes.sSpacing, 'all' )#">
<cfelse>
  <cfhtmlhead text="#sHeaderText#">
</cfif>
 
<cfsetting enablecfoutputonly="No">